function processKTHPose( rootdir )
%processPose - pre-process all pose data by first transforming the
% data into a more familiar format, and then smoothing.

% Examples:
%   rootdir = '/Users/trananh/Desktop/gestures/KTH/ground-truth';
  
  clc;
  
  if ~strcmp(rootdir(end), '/')
    rootdir = [rootdir '/'];
  end
  
  % Iterate over each action in the rootdir
  addpath ../utils
  actions = getSubDirectories(rootdir);
  for i = 1:numel(actions)
    action = [actions{i} '/'];
    
    % Iterate over each clip for the action
    clips = getSubDirectories(action);
    for j = 1:numel(clips)
      clip = [clips{j} '/'];
      
      % Iterate over each segment for the clip
      segments = getSubDirectories(clip);
      for k = 1:numel(segments)
        segment = [segments{k} '/'];
        
        % Make sure it's a valid segment
        if ~isempty(regexp(segment, '.*\d{5}-\d{5}/$', 'once'))
          
          % Reformat pose
          tracksfile = [segment 'skeleton/tracks.txt'];
          tracksdir = [segment 'skeleton-tracks-raw/'];
          poseReformat(tracksfile, tracksdir);
          
          % Smooth pose
          smoothdir = [segment 'skeleton-tracks/'];
          poseSmoothing(tracksdir, smoothdir);
          
          % Standardize pose
          stddir = [segment 'skeleton-tracks-std/'];
          poseStandardize(smoothdir, stddir);
          
        end
      end
    end
  end
  
end
